ListNode* partition(ListNode* pHead, int x)
{
	struct ListNode*gGuard,*gtail,*lGuard,*ltail;
	gGuard=gtail= (struct ListNode*)malloc(sizeof(struct ListNode));
	lGuard=ltail= (struct ListNode*)malloc(sizeof(struct ListNode));
	gtail->next=NULL;
	ltail->next=NULL;
	
	struct ListNode* cur=pHead;
	while(cur)
	{
		if(cur->val<x)
		{
			ltail->next=cur;
			ltail=ltail->next;
		}
		else
		{
			gtail->next=cur;
			gtail=gtail->next;
		}
		cur=cur->next;
	}
	ltail->next=gGuard->next;
	gtail->next=NULL;
	pHead=lGuard->next;
	free(gGuard);
	free(lGuard);
	return pHead;
	
}
